﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:lakana="clr-namespace:GasyTek.Lakana.Navigation.Controls"
                    xmlns:resources="clr-namespace:GasyTek.Lakana.Navigation.Resources"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:services="clr-namespace:GasyTek.Lakana.Navigation.Services">

    <!-- ShutdownApplicationWindow styles -->

    <Style x:Key="{x:Static lakana:ShutdownApplicationWindow.ShutdownApplicationItemStyleKey}"
           TargetType="lakana:ShutdownApplicationItem">
        <Setter Property="TargetViewInstanceKey"
                Value="{Binding ViewInstanceKey, Mode=OneWay}" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush"
                Value="LightGray" />
        <Setter Property="Cursor"
                Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="lakana:ShutdownApplicationItem">
                    <Border x:Name="outerBorder"
                            Margin="3"
                            Padding="3"
                            CornerRadius="2"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}">
                        <ContentPresenter ContentSource="Content"
                                          ContentTemplate="{TemplateBinding ContentTemplate}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True"
                                 SourceName="outerBorder">
                            <Setter Property="Background"
                                    TargetName="outerBorder">
                                <Setter.Value>
                                    <SolidColorBrush Color="LightBlue"
                                                     Opacity="0.5" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate DataType="services:View">
                    <Grid>
                        <Grid.Resources>
                            <sys:String x:Key="NoIcon">
                                pack://application:,,,/GasyTek.Lakana.Navigation;component/Resources/Images/runningTask.png
                            </sys:String>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding UIMetadata.Icon, TargetNullValue={StaticResource NoIcon}, FallbackValue={StaticResource NoIcon}}"
                               Width="32"
                               Height="32" />
                        <TextBlock Grid.Column="1"
                                   Text="{Binding UIMetadata.Label}"
                                   Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   TextTrimming="CharacterEllipsis" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static lakana:ShutdownApplicationWindow.ShutdownApplicationItemsControlStyleKey}"
           TargetType="lakana:ShutdownApplicationItemsControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ItemsControl">
                    <Border>
                        <ScrollViewer HorizontalScrollBarVisibility="Hidden"
                                      VerticalScrollBarVisibility="Auto">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="{x:Static lakana:ShutdownApplicationWindow.CancelButtonStyleKey}"
           TargetType="Button">
        <Setter Property="Width"
                Value="100" />
        <Setter Property="Margin"
                Value="10,0,0,0" />
        <Setter Property="Foreground"
                Value="Black" />
    </Style>

    <Style x:Key="{x:Static lakana:ShutdownApplicationWindow.ExitButtonStyleKey}"
           TargetType="Button">
        <Setter Property="Foreground"
                Value="Black" />
    </Style>

    <Style x:Key="{x:Type lakana:ShutdownApplicationWindow}"
           TargetType="lakana:ShutdownApplicationWindow">
        <Setter Property="Background"
                Value="#FF353535" />
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="ShowInTaskbar"
                Value="False" />
        <Setter Property="WindowStyle"
                Value="ToolWindow" />
        <Setter Property="SizeToContent"
                Value="WidthAndHeight" />
        <Setter Property="ResizeMode" 
                Value="NoResize" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="lakana:ShutdownApplicationWindow">
                    <Border x:Name="outerBorder"
                            Width="400"
                            Height="300"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="0">
                        <Grid Margin="15">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <TextBlock Text="{x:Static resources:Labels.RunningTasks}"
                                       FontSize="22"
                                       FontWeight="SemiBold" />
                            
                            <TextBlock Grid.Row="1"
                                       Text="{x:Static resources:Labels.ClickTaskToCloseItGracefully}"
                                       Margin="20,10,20,10"
                                       TextWrapping="Wrap" />

                            <lakana:ShutdownApplicationItemsControl 
                                    Grid.Row="2"
                                    x:Name="PART_Views"
                                    ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Views}"
                                    ItemContainerStyle="{DynamicResource {x:Static lakana:ShutdownApplicationWindow.ShutdownApplicationItemStyleKey}}"
                                    Style="{DynamicResource {x:Static lakana:ShutdownApplicationWindow.ShutdownApplicationItemsControlStyleKey}}"
                                    />

                            <Grid Grid.Row="3"
                                  Margin="0,10,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Button x:Name="PART_ExitApplication"
                                        Content="{x:Static resources:Labels.ExitApplication}"
                                        Style="{DynamicResource {x:Static lakana:ShutdownApplicationWindow.ExitButtonStyleKey}}" />
                                <Button Grid.Column="1"
                                        x:Name="PART_Cancel"
                                        Content="{x:Static resources:Labels.Cancel}"
                                        Style="{DynamicResource {x:Static lakana:ShutdownApplicationWindow.CancelButtonStyleKey}}" />
                            </Grid>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>